package com.codejiwei.core.rdd

import org.apache.spark.{SparkConf, SparkContext}

object Spark_Operator_GroupBy {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[1]").setAppName("GroupBy")
    val sc = new SparkContext(conf)

    val rdd = sc.makeRDD(List(1, 2, 3, 4, 5), 2)

    rdd.groupBy(data => data % 2, 3)
      .map{
        case(i, l) => l.toList
      }
      .collect()
      .foreach(println)

    sc.stop()
  }
}
